
import { ViteSSG } from 'vite-ssg '
// import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import { routes } from './router'

import './assets/main.css'



export const createApp = ViteSSG(App, {
    routes
},({app, router, initialState})=>{
    const pinia = createPinia()

    app.use(pinia)

    // set values during build time
    if(import.meta.env.SSR) initialState.pinia = pinia.state.value
    else pinia.state.value = initialState.pinia || {}

    // All this run during run time

    router.beforeEach((to, form, next)=>{
        // do something here
        next() 
    })
})
// const app = createApp(App)

// app.use(createPinia())
// app.use(router)

// app.mount('#app')

export async function includeedRoutes(
    paths: string[],
    routes: RouteRecordRaw[]
){
    // runs during build time

    return Promise.all(
        routes.map(async (route)=>{
            return route.path
        })
    )
}